package codename.carrot.bomberman.models;

import codename.carrot.bomberman.BitmapFactory;
import codename.carrot.bomberman.controllers.ItemContainerController;
import codename.carrot.bomberman.game.listener.ObstacleListener;

/**
 * Class representing item-containers in the game
 * @author Group A4
 *  @see ItemContainerController The controller for this model 
 */
public class ItemContainer extends AbstractObstacle {
	/**
	 *  The item this container contains, null if it does not contain anything
	 */
    private CollectableItem item;
    
    /**
     *  Constructor
     * @param xCoor the x-coordinate of the item
     * @param yCoor the y-coordinate of the item
     * @param listener the listener of this item container
     * @param item the item it contains (null if none)
     */
	public ItemContainer(int xCoor, int yCoor, ObstacleListener listener, CollectableItem item) {
	    super(xCoor, yCoor,  BitmapFactory.buildItemContainerImage(), listener);
	    this.item = item;
	    setVisible(true);
	}
	
    @Override
    public boolean isDestructible() {
        return true;
    }
	
    /**
     *  Returns the item in this item-container
     * @return
     */
	public CollectableItem getItem() {
	    return item;
	}
	
	/**
	 *  Sets an item in this item-container
	 * @param item
	 */
	public void setItem(CollectableItem item) {
	    this.item = item;
	}
	
	/**
	 *  Returns true if this item-container contains an item
	 * @return true | false
	 */
	public boolean hasItem() {
	    return item != null;
	}
		
}
